//
//  ZYCTeaAttendanceStatisticsAttendanceCell.m
//  ZDSC
//
//  Created by 张威 on 2021/10/22.
//

#import "ZYCTeaAttendanceStatisticsAttendanceCell.h"
#import "ZYCAttendanceStatusGroupView.h"
#import "ZYCTeaLeaveStatisticsModel.h"

@interface ZYCTeaAttendanceStatisticsAttendanceCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *line;
//正常
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *noramlGroupView;
//迟到
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *lateGroupView;
//早退
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *leaveEarlyGroupView;
//缺卡
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *missingCardGroupView;

@end
@implementation ZYCTeaAttendanceStatisticsAttendanceCell

- (void)setModel:(ZYCTeaLeaveStatisticsModel *)model{
    _model = model;
    _noramlGroupView.count = model.countZC;
    _lateGroupView.count = model.countCD;
    _leaveEarlyGroupView.count = model.countZT;
    _missingCardGroupView.count = model.countQK;
}

- (void)setHeader:(NSString *)header{
    _header = header;
    _titleLabel.text = header;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.line];
        [self.contentView addSubview:self.noramlGroupView];
        [self.contentView addSubview:self.lateGroupView];
        [self.contentView addSubview:self.leaveEarlyGroupView];
        [self.contentView addSubview:self.missingCardGroupView];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(19.0f);
            make.top.equalTo(self.contentView).offset(20.0f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.contentView);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(17.0f);
            make.height.mas_equalTo(1);
        }];
        
        CGFloat margin  = (kScreenWidth  - 50 * 4) / 5;
        
        [self.noramlGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.contentView).offset(margin);
            make.top.equalTo(self.line.mas_bottom).offset(20.0f);
        }];
        
        [self.lateGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.noramlGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.noramlGroupView);
        }];
        
        [self.leaveEarlyGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.lateGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.noramlGroupView);
        }];
        [self.missingCardGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.leaveEarlyGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.noramlGroupView);
        }];
    }
    return self;
}
- (ZYCAttendanceStatusGroupView *)noramlGroupView {
    if (!_noramlGroupView) {
        _noramlGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _noramlGroupView.color = HEX_RGB(@"#39A85B");
        _noramlGroupView.title = @"正常";
    }
    return _noramlGroupView;
}

- (ZYCAttendanceStatusGroupView *)lateGroupView {
    if (!_lateGroupView) {
        _lateGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _lateGroupView.color = HEX_RGB(@"#E93C06");
        _lateGroupView.title = @"迟到";
    }
    return _lateGroupView;
}

- (ZYCAttendanceStatusGroupView *)leaveEarlyGroupView {
    if (!_leaveEarlyGroupView) {
        _leaveEarlyGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _leaveEarlyGroupView.color = HEX_RGB(@"#FDA252");
        _leaveEarlyGroupView.title = @"早退";
    }
    return _leaveEarlyGroupView;
}


- (ZYCAttendanceStatusGroupView *)missingCardGroupView {
    if (!_missingCardGroupView) {
        _missingCardGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _missingCardGroupView.color = HEX_RGB(@"#B9B9B9");
        _missingCardGroupView.title = @"缺卡";
    }
    return _missingCardGroupView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#FAFAFA");
    }
    return _line;
}

@end
